package com.sf.marathon.soul.service;

import java.util.List;

import org.springframework.stereotype.Service;

import com.sf.marathon.soul.core.base.BaseService;
import com.sf.marathon.soul.core.util.BeanMapper;
import com.sf.marathon.soul.core.util.Collections3;
import com.sf.marathon.soul.dao.UserMapper;
import com.sf.marathon.soul.domain.User;
import com.sf.marathon.soul.vo.UserVO;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author 01368146
 * @since 2017-08-11
 */
@Service
public class UserService extends BaseService<UserMapper, User> {

    public User findByUserCode(String userCode) {
        List<User> users = baseDao.selectByUserCode(userCode);
        if (Collections3.isNotEmpty(users)) {
            return users.get(0);
        } else {
            return null;
        }
    }

    public UserVO login(String userCode, String password) {
        User m = baseDao.selectByUserCodeAndPassword(userCode, password);
        return BeanMapper.map(m, UserVO.class);
    }
}
